<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>轮播图管理</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="${s.base}/js/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="${s.base}/css/base/base.css" media="all" />
</head>
<body class="childrenBody">
<form class="layui-form">
	<blockquote class="layui-elem-quote quoteBox">
		<form class="layui-form">
			<div class="layui-inline">
				<label class="layui-input-inline">联系人：</label>

				<div class="layui-input-inline">
					<input type="text" class="layui-input" id="linkUser" placeholder="请输入联系人" />
				</div>
				<label class="layui-input-inline">手机号：</label>
				<div class="layui-input-inline">
					<input type="text" class="layui-input" id="phone" placeholder="请输入手机号" />
				</div>
				<label class="layui-input-inline">预约产品：</label>
				<div class="layui-input-inline">
					<input type="text" class="layui-input" id="productName" placeholder="请输入预约产品" />
				</div>
				<label class="layui-input-inline">状态：</label>
				<div class="layui-input-inline">
					<select class="layui-input" id="type">
						<option value="">全部</option>
						<option value="1">待支付</option>
						<option value="2">已支付</option>
					</select>
				</div>
				<a class="layui-btn search_btn" data-type="reload">搜索</a>
			</div>
			<div class="layui-inline">
				<a class="layui-btn layui-btn-normal add_btn">添加</a>
			</div>
		</form>
	</blockquote>
	<table id="entityList" lay-filter="entityList"></table>

</form>
<script type="text/javascript" src="${s.base}/js/layui/layui.js"></script>
<script type="text/javascript" src="${s.base}/js/base/base.js"></script>
<script type="text/javascript">
    layui.use(['form','layer','laydate','table','laytpl'],function(){
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery,
            laydate = layui.laydate,
            laytpl = layui.laytpl,
            table = layui.table;

        //列表
        var tableIns = table.render({
            elem: '#entityList',
            url : '/webDetail/jsonList',
            cellMinWidth : 95,
            page : true,
            height : "full-125",
            limit : 20,
            method:'post',
            limits : [10,15,20,25],
            id : "entityList",
            cols : [[
                {type: 'numbers', title: '序号'},
                {field: 'id', title: '主键',align:'center'},
                {field: 'linkUser', title: '联系人',align:'center'},
                {field: 'phone', title: '联系电话',align:'center'},
                {field: 'productName', title: '预约产品',align:'center',width:300},
                {field: 'type', title: '状态',align:'center',templet:function(d){
                    if(d.type=="1"){
                        return "待支付";
                    }else if(d.type=="2"){
                        return "已支付";
                    }
                }},
                {field: 'createTime', title: '提交时间', align:'center', minWidth:110, templet:function(d){
                    return timeStamp2String(d.createTime);
                }},
                {field: 'updateTime', title: '支付时间', align:'center', minWidth:110, templet:function(d){
                    if(d.type=="1"){
                        return "";
                    }else if(d.type=="2"){
                        return timeStamp2String(d.updateTime);
                    }

                }},

                {title: '操作',width:170,align:"center", templet:function(d){
                    if(d.type=="1"){
                        return '<a class="layui-btn layui-btn-xs" lay-event="edit">立即支付</a>';
                    }else if(d.type=="2"){
                        return '<a class="layui-btn layui-btn-xs layui-btn-disabled" >已经支付</a>';
                    }

                }}
            ]]
        });

        //搜索
        $(".search_btn").on("click",function(){
            table.reload("entityList",{
                page: {
                    curr: 1 //重新从第 1 页开始
                },
                where: {
                    linkUser: $("#linkUser").val(),
                    phone: $("#phone").val(),
                    productName: $("#productName").val(),
                    type: $("#type").val()
                }
            })
        });

        //列表操作
        table.on('tool(entityList)', function(obj){
            var layEvent = obj.event,
                data = obj.data;
            if(layEvent === 'edit'){
                layer.confirm('确定用户【'+data.linkUser+'】已经支付了吗？',{icon:3, title:'提示信息'},function(index){
                    $.get("/webDetail/doEntity",{
                        "id":data.id
                    },function(result){
                        if(1==result.returnInfo.state){
                            tableIns.reload();
                            layer.close(index);
                        }else{
                            top.layer.msg(result.returnInfo.errorMsg);
                        }
                    })
                });
            }
        });

    })
</script>
</body>
</html>